@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/list";
		var _colnames = ["主键", 
						"名称",
		"设置价格"];
		var _colmodel = [{name:"id", index:"id",hidden:true, width:10},
						{name:"name", index:"name", width:100},
			{name:"id", index:"id", width:50,formatter:function (value ,rows, index) {

			    if(value === 4){
                    console.log(value)
                    return "<button id='setprice' onclick='settype("+value+")' class='btn btn-white'>材料管理</button>" +
                        "&nbsp;&nbsp;<button id='setprice' onclick='setprice1("+value+")' class='btn btn-white'>设置开数</button>";
				}else {
                    return "<button id='setprice' onclick='settype("+value+")' class='btn btn-white'>材料管理</button>" +
                        "&nbsp;&nbsp;<button id='setprice' onclick='setprice("+value+")' class='btn btn-white'>设置价格</button>";
				}

			}}
		];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id", order : "desc"}
		});
	}
</script>
<script>
    settype = function (pid) {
        window.location.href = "/producttype/"+pid;
    }
	setprice = function (pid) {
		window.location.href = "/producttech/"+pid;
	}
    setprice1 = function (pid) {
        window.location.href = "/producttech/"+pid+"-2";
    }
</script>

	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			@ var _col=[
			@		{name:"", index:"name", type:"text"}
			@];
			@ include("/common/_function/_search.html",{"col":_col}){}
			<!-- 按钮 -->
			<div class="welljq well-sm" id="btns"></div>
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	
@}	